import socket

sk = socket.socket(type=socket.SOCK_DGRAM)

sk.bind(('127.0.0.1', 9001))
while True:
    msg, addr = sk.recvfrom(1024)
    while True:
        try:
            print(msg.decode('utf8'))
            sk.sendto('服务端已经接收了数据'.encode('utf8'), addr)
        except:
            print("退出")
            break